'use strict';

const Controller = require('egg').Controller;

class CollectsController extends Controller {

    // 收藏
    async collectupload() {
        const { ctx, app } = this;

        let res = { code: 1, msg: '成功' };
        // 模拟文章id

        let sql = `SELECT a.aid,a.title, a.content, u.username, u.avater, u.fans, a.supports, a.collects, a.addtimes,u.introduce  
        FROM articles AS a, collects AS c, users AS u where c.aid = a.aid AND c.uid = u.uid; `
        const findresult = await app.mysql.query(sql);
        console.log(findresult);
        res.data = findresult;
        ctx.body = res;
    }

    // 点赞
    async supportsupload() {
        const { ctx, app } = this;

        let res = { code: 1, msg: '成功' };
        // 模拟文章id

        let sql = `SELECT a.title, a.content, u.username, u.avater, u.fans, a.supports, a.collects, a.addtimes, u.introduce 
        FROM articles AS a ,supports AS s, users AS u where s.aid = a.aid AND s.uid = u.uid; `
        const findresult = await app.mysql.query(sql);
        console.log(findresult);
        res.data = findresult;
        ctx.body = res;
    }

}

module.exports = CollectsController;